#include "average_help.h"

void average_help( FILE* fp , int n , int counts[] )
{
	char temp = 0 ;
	int index = 0 ;
	int i = 0 ;

	while ( (temp = fgetc(fp)) != EOF )
	{
		if ( (temp>='0')&&(temp<='9') )
		{
			index = index*10 + temp - '0' ;
		}
		if ( temp == ' ' ) 
		{
			counts[i] = index ;
			i = i + 1 ;
			index = 0 ;
		}		
	}
}

void cal_average( int counts[] , int n , int start , int finish , int& average )
{
	int num = finish - start + 1 ;
	long long sum = 0 ; 
	for ( int i = 0 ; i < num ; ++i )
	{
		sum = sum + counts[start+i] ;
	}
	average = sum / num ;
}